//author:kakake
class tsFrontShowDao {
    public data = {
        //42.192.250.43
        //10.0.4.5
        dbConn: TSLobsterAPI.DbHelper.setdbconn('42.192.250.43', 'CloudCMS', 'sa', 'Lobster@123')
    }

    public getindexdata(websiteid:any){
        var strsql = "select * from CMS_IndexSetting where websiteid=@websiteid and delflag=0";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, {websiteid:websiteid}, null);
    }

    public getindexdata2(websiteid:any,workid:any){
        var strsql = "select * from CMS_IndexSetting where workid=@workid and websiteid=@websiteid";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, {workid:workid,websiteid:websiteid}, null);
    }

    public gettitledata(websiteid:any,workid:any){
        var strsql = "select nid,nodename from cms_node where workid=@workid and websiteid=@websiteid and nodestatus=1 and ParentID=-1 and IsDel=0 Order by NodeSort";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, {workid:workid,websiteid:websiteid}, null);
    }

    public getitemdata(id:any,pageInfo:object){
        var strsql = "SELECT ID,CID,NodeID,Title,Intraduce,PicPath,ReleaseTime,TotalHit FROM CMS_BaseContext \
        where NodeID=@id and IsDel=0 and Status=99";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, {id:id}, pageInfo);
    }

    public getcontextdata(id:any){
        var strsql = "SELECT a.CID,NodeID,Title,Intraduce,PicPath,ReleaseTime,b.U_Cont,a.TotalHit,a.LastUpdateTime FROM CMS_BaseContext a\
        LEFT JOIN CMS_U_Article b on a.ID=b.ID \
        where a.ID=@id";
        return TSLobsterAPI.DbHelper.DbGetJsonObject(this.data.dbConn, strsql, {id:id});
    }

    public updatetotalhit(cid:any){
        var strsql = "update CMS_BaseContext set TotalHit=TotalHit+1 where Cid=@cid;\
           update CMS_BaseContextManage set TotalHit=TotalHit+1 where Cid=@cid";
        return TSLobsterAPI.DbHelper.DbExecuteUpdate(this.data.dbConn,strsql,{cid:cid});
    }
}